#include <iostream>
#include <string>
#include <sstream>
#include <map>
#include <iomanip>

using namespace std;

map<string, int> word;
int most;
string mostWord;

int main()
{
	string s;

	word.clear();
	most = -1;
	mostWord = "";

	while (true)
	{
		getline(cin, s);
		if (s == "") break;

		if (s == "#" && most > -1) 
		{
			cout << setw(4) << most << " " << mostWord << endl;
			word.clear();
			most = -1;
			mostWord = "";
		}
		else
		{
			for (int i = (int) s.size()-1; i>= 0; i--)
			{
				if ('A' <= s[i] && s[i] <= 'Z') s[i] = s[i] - 'A' + 'a';

				if (!('a' <= s[i] && s[i] <= 'z')) s[i] = ' ';
			}

			stringstream ss(s);
			string c;
			while (ss >> c)
			{
				if (word.find(c) == word.end()) word[c] = 1;
				else word[c]++;

				if (word[c] > most) 
				{
					most = word[c];
					mostWord = c;
				}
			}
		}
	}
	return 0;
}
